<?php

class Core_Backend_Component_Website_View_Template_Index extends Core_Backend_Share_View_Grid {

    public function __construst() {
        parent::__construct();
    }

    protected function buildNavigation($navigation) {
        $navigation->addLabel($this->__('website.title.template_index'));
        parent::navigation($navigation);
    }

    protected function buildToolbar($toolbar) {
    	parent::buildToolbar($toolbar);
    	$group = $toolbar->createGroup();
        $group->addLink($this->getUrl(array('areaid'=>$this->getCurrentAreaId()), 'create'), $this->__('share.button.create'));
    }

    protected function buildGrid($grid) {
    	$this->getTemplate()->assignMulti(array('areas'=>$this->getAreas(), 'current_area_id'=>$this->getCurrentAreaId()));
        $grid->setId('template_grid')
                ->setPrimaryKey('id')
                ->setSortField($this->getRequest()->getQuery('sort', 'id'))
                ->setSortDirection($this->getRequest()->getQuery('dir', 'asc'))
                ->setSortUrlFormat($this->getSortUrl())
                ->addLabelColumn($this->__('share.label.name'), 'name', '{name}')
                ->setSortField('name')
                ->getGrid()
                ->addLabelColumn($this->__('share.label.theme'), 'theme', '{theme}')
                ->setSortField('theme')
                ->setWidth(200)
                ->getGrid()
                ->addLabelColumn($this->__('share.label.skin'), 'skin', '{skin}')
                ->setSortField('skin')
                ->setWidth(200)
                ->getGrid()
                ->addLabelColumn($this->__('global.label.layout'), 'layout', '{layout}')
                ->setSortField('layout')
                ->setWidth(200)
                ->getGrid()
                ->addLabelColumn($this->__('global.label.position'), 'position', '{position}')
                ->setWidth(200)
                ->getGrid()
                ->addLinkColumn('#', 'edit', $this->getUrl(array('id' => '{id}'), 'edit'), $this->__('share.button.edit'))
                ->setWidth(40)
                ->setAlign('center')
                ->getGrid()
                ->setDataSource($this->getList()->toArray());
        parent::buildGrid($grid);
    }

    protected function buildPagination($pagination) {
        $pagination->setUrlFormat($this->getPaginationUrl())->setRecordCount($this->getRecords());
        parent::buildPagination($pagination);
    }
}

